package com.sskj.login.presenter;

import com.alibaba.android.arouter.launcher.ARouter;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.router.provider.SendSmsProvider;
import com.sskj.login.http.HttpConfig;
import com.sskj.login.ui.activity.PwdForgetActivity;


public class PwdForgetActivityPresenter extends BasePresenter<PwdForgetActivity> {


    /**
     * 重置登录密码
     *
     * @param mobile 手机号/邮箱号
     * @param opwd   密码
     * @param opwd1  确认登录密码
     * @param code   验证码
     * @return
     */
    public void resetLoginPwd(String mcode, String mobile, String opwd, String opwd1, String code) {
        httpService.resetLoginPwd(mcode, mobile, opwd, opwd1, code).execute(new JsonCallBack<HttpData>(this) {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.resetPwdSuccess();
                }
            }
        });
    }


    public void sendCode(String mcode, String mobile) {
        SendSmsProvider navigation = ARouter.getInstance().navigation(SendSmsProvider.class);
        navigation.send(this,mobile, mcode,"1", new SendSmsProvider.OnSend() {
            @Override
            public void onSuccess() {
                mView.sendCheckCodeSuccess();
            }

            @Override
            public void onFail() {
                mView.sendCheckCodeFail();
            }
        });

    }
}
